<?php

namespace app\admin\model;

use think\Model;


class Cheliang extends Model
{

    // 表名
    protected $table = 'whqy_cheliang';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];


    public function getOriginData()
    {
        return $this->origin;
    }

    protected static function init()
    {

        self::beforeInsert(function ($row) {

            if (isset($row['owner_id'])) {
                if ($row['owner_id']) {
                    $row->owner = get_user($row['owner_id']);
                }
            }
        });


        self::beforeUpdate(function ($row) {
            $changed = $row->getChangedData();
            //如果有修改密码
            if (isset($changed['owner_id'])) {
                if ($changed['owner_id']) {

                    $row->owner = get_user($row['owner_id']);
                }
            }
        });
    }







}
